package Client;
import java.io.Serializable;

import javax.swing.ImageIcon;

/**
 * Card.
 * have Value(ImageIcon), faceup(true when visible)
 * @author Termchai 5510546042, Eknarin 5510546239
 *
 */
public class Card implements Serializable{
	
	private boolean faceUp = false; 
	private ImageIcon icon;
	
	private int[] location;

	/**
	 * @param icon ImageIcon of this card
	 * @param location location (x,y)
	 */
	public Card(ImageIcon icon,int[] location) {
		// TODO Auto-generated constructor stub
		this.icon=icon;
		this.location=location;
	}
	
	/**
	 * setVisible
	 * @param boo boolean
	 */
	public void setFaceUp(boolean boo)
	{
		faceUp = boo;
	}
	
	/**
	 * @return true if this card faceup
	 */
	public boolean isFaceUp()
	{
		return faceUp;
	}

	/**
	 * 
	 * @return ImageIcon of this card
	 */
	public ImageIcon getValue()
	{
		return icon;
	}
	
	/**
	 * 
	 * @return return location (array of int){x,y}
	 */
	public int[] getLocation()
	{
		return location;
	}
	/**
	 * check this card equal to other card?
	 * @param obj other card
	 * @return true if equal
	 */
	public boolean match(Object obj)
	{
		if (obj==null) 
			return false;
		if (obj.getClass()!=this.getClass()) 
			return false;
		Card another = (Card)obj;
		if (this.getValue()==another.getValue()) 
			return true;
		return false;
	}
	
	public String toString()
	{
		return "Location : " +location[0] + "," + location[1] + " || Value : ";
	}
	
}
